from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# 创建项目对象
app = Flask(__name__,
            template_folder="templates",
            static_folder="static")

app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:ABCabc123@sh-cynosdbmysql-grp-43j5vxfg.sql.tencentcdb.com:22939/flaskdb"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
"""模型创建"""

db = SQLAlchemy(app)

class User(db.Model):
    #定义表名
    __tablename__ = 'users'
    #定义字段对象
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(10),unique=True)
    password = db.Column(db.String(16))

    def __repr__(self) -> str:
        return 'User:%s'% self.username